SYMBOLS {
    __STACKSIZE__:   type = weak,   value = $0800; # 2k stack
    __LOADADDR__:  type = import;
    __EXEHDR__:    type = import;   
    __MLS_SIZE__:    type = weak, value = $0200;
    __STRUCTS_SIZE__:   type=weak, value = $0400; 
	__END_OF_RAM__: type=weak, value = $D000 - __STACKSIZE__ - __MLS_SIZE__ - __STRUCTS_SIZE__;
	__OVERLAY_START__: type=weak, value = $7B00;
	__OVERLAY_SIZE__: type=weak, value = __END_OF_RAM__ - __OVERLAY_START__;
    __EDIT_BUFFER_SIZE__: type=weak, value=$2000;
    __EDIT_BUFFER_START__: type=weak, value = __END_OF_RAM__ - __EDIT_BUFFER_SIZE__;
    __EMPIRE_BUFFER_SIZE__: type=weak, value=$0680;
    __EMPIRE_BUFFER_START__: type=weak, value = __END_OF_RAM__ - __EMPIRE_BUFFER_SIZE__;
}
MEMORY {
    ZP:       define = yes,	start = $0002,				size = $001A,					file = "";
    LOADADDR: 				start = $07FF,				size = $0002,					file = %O;
    HEADER:   				start = $0801,				size = $000C,					file = %O;
    STACK:                  start = $D000 - __STACKSIZE__, size = __STACKSIZE__,        file = "";
    RAM:      define = yes,	start = $080D,				size = __OVERLAY_START__ - $080D - __STACKSIZE__,	file = %O;
	LOGINLA:  define = yes, start = __OVERLAY_START__,	size = $0002,					file = "bbs.login.c64";
	LOGIN:	  define = yes, start = __OVERLAY_START__,	size = __OVERLAY_SIZE__,		file = "bbs.login.c64"; #,	fill=yes, fillval=$ff;
	WAITLA:	  define = yes, start = __OVERLAY_START__,	size = $0002,					file = "bbs.wait.c64";
	WAIT:	  define = yes, start = __OVERLAY_START__,	size = __OVERLAY_SIZE__,		file = "bbs.wait.c64"; #,	fill=yes, fillval=$ff;
	MAINLA:	  define = yes, start = __OVERLAY_START__,	size = $0002,					file = "bbs.main.c64";
	MAIN:	  define = yes, start = __OVERLAY_START__,	size = __OVERLAY_SIZE__,		file = "bbs.main.c64"; #,	fill=yes, fillval=$ff;
	USERLA:	  define = yes, start = __OVERLAY_START__,	size = $0002,					file = "bbs.user.c64";
	USER:	  define = yes, start = __OVERLAY_START__,	size = __OVERLAY_SIZE__,		file = "bbs.user.c64"; #,	fill=yes, fillval=$ff;
	SUBSLA:	  define = yes, start = __OVERLAY_START__,	size = $0002,					file = "bbs.subs.c64";
	SUBS:	  define = yes, start = __OVERLAY_START__,	size = __OVERLAY_SIZE__,		file = "bbs.subs.c64"; #,	fill=yes, fillval=$ff;
	EDITLA:	  define = yes, start = __OVERLAY_START__,	size = $0002,					file = "bbs.edit.c64";
	EDIT:	  define = yes, start = __OVERLAY_START__,	size = __OVERLAY_SIZE__ - __EDIT_BUFFER_SIZE__,	file = "bbs.edit.c64"; #,	fill=yes, fillval=$ff;
	NEWLA:	  define = yes, start = __OVERLAY_START__,	size = $0002,					file = "bbs.new.c64";
	NEW:	  define = yes, start = __OVERLAY_START__,	size = __OVERLAY_SIZE__,		file = "bbs.new.c64"; #,	fill=yes, fillval=$ff;
	EMPIRELA: define = yes, start = __OVERLAY_START__,	size = $0002,					file = "bbs.empire.c64";
	EMPIRE:	  define = yes, start = __OVERLAY_START__,	size = __OVERLAY_SIZE__ - __EMPIRE_BUFFER_SIZE__, file = "bbs.empire.c64"; #,	fill=yes, fillval=$ff;
	EMPIRECLA: define = yes, start = __OVERLAY_START__,	size = $0002,					file = "bbs.empirec.c64";
	EMPIREC:  define = yes, start = __OVERLAY_START__,	size = __OVERLAY_SIZE__ - __EMPIRE_BUFFER_SIZE__, file = "bbs.empirec.c64"; #,	fill=yes, fillval=$ff;
	TAPE:	  define = yes,	start = $033C,				size = $00BF,	fill = no,		file = "";
    STRUCTS:  define = yes, start = __END_OF_RAM__,              size = __STRUCTS_SIZE__,   fill = no,      file = "";
    EDITB:    define = yes, start = __EDIT_BUFFER_START__, size = __EDIT_BUFFER_SIZE__, file = "";
    EMPIREB:  define = yes, start = __EMPIRE_BUFFER_START__, size = __EMPIRE_BUFFER_SIZE__, file = "";
    MLADDR:   define = yes, start = __END_OF_RAM__ + __STRUCTS_SIZE__,              size = $0002,                   file = "rs232-c64.ml";
    ML:       define = yes, start = __END_OF_RAM__ + __STRUCTS_SIZE__,              size = __MLS_SIZE__,                   file = "rs232-c64.ml";
}
SEGMENTS {
    LOADADDR: load = LOADADDR, type = ro;
    EXEHDR:   load = HEADER,   type = ro;
    STARTUP:  load = RAM,      type = ro;
    LOWCODE:  load = RAM,      type = ro,                optional = yes;
    INIT:     load = RAM,      type = ro,  define = yes, optional = yes;
    CODE:     load = RAM,      type = ro;
    RODATA:   load = RAM,      type = ro;
    DATA:     load = RAM,      type = rw;
    ZPSAVE:   load = RAM,      type = bss;
    BSS:      load = RAM,      type = bss, define = yes;
    ZEROPAGE: load = ZP,       type = zp;
    STRUCTBSS: load=STRUCTS,   type = bss, define = yes;

	# OVERLAYS
	LOGINLA:	load = LOGINLA,	type = ro;
	LOGINCODE:	load = LOGIN,	type = ro,	define = yes;
	LOGINDATA:	load = LOGIN,	type = rw;
    LOGINBSS:   load = LOGIN,   type = bss, define = yes;
	WAITLA:		load = WAITLA,	type = ro;
	WAITCODE:	load = WAIT,	type = ro,	define = yes;
	WAITDATA:	load = WAIT,	type = rw;
    WAITBSS:    load = WAIT,    type = bss;
	MAINLA:		load = MAINLA,	type = ro;
	MAINCODE:	load = MAIN,	type = ro,	define = yes;
	MAINDATA:	load = MAIN,	type = rw;
    MAINBSS:    load = MAIN,    type = bss;
	SUBSLA:		load = SUBSLA,	type = ro;
	SUBSCODE:	load = SUBS,	type = ro,	define = yes;
	SUBSDATA:	load = SUBS,	type = rw;
    SUBSBSS:    load = SUBS,    type = bss, define = yes;
	NEWLA:		load = NEWLA,	type = ro;
	NEWCODE:	load = NEW,	    type = ro,	define = yes;
	NEWDATA:	load = NEW,	    type = rw;
    NEWBSS:     load = NEW,     type = bss, define = yes;
	EMPIRELA:	load = EMPIRELA, type = ro;
	EMPIRECODE:	load = EMPIRE,	type = ro,	define = yes;
	EMPIREDATA:	load = EMPIRE,	type = rw;
    EMPIREBSS:  load = EMPIRE,  type = bss, define = yes;
	EMPIRECLA:	load = EMPIRECLA, type = ro;
	EMPIRECCODE:	load = EMPIREC,	type = ro,	define = yes;
	EMPIRECDATA:	load = EMPIREC,	type = rw;
    EMPIRECBSS:  load = EMPIREC,  type = bss, define = yes;
	EMPIREBUF:	load = EMPIREB,	type = bss, define = yes;
	USERLA:		load = USERLA,	type = ro;
	USERCODE:	load = USER,	type = ro,	define = yes;
	USERDATA:	load = USER,	type = rw;
    USERBSS:    load = USER,    type = bss, define = yes;
	EDITLA:		load = EDITLA,	type = ro;
	EDITCODE:	load = EDIT,	type = ro,	define = yes;
	EDITDATA:	load = EDIT,	type = rw;
    EDITBSS:    load = EDIT,    type = bss, define = yes;
    EDITBUF:    load = EDITB,   type = bss, define = yes;

	# The TAPEBUFFER segment is used to hold the user record for the 
	# currently logged in user.
	TAPEBUFFER: load=TAPE,	   type = bss, define = yes;

    MLADDR:   load = MLADDR,   type = ro;
    ML:       load = ML,       type = rw, define = yes;
}
FEATURES {
    CONDES: type    = constructor,
            label   = __CONSTRUCTOR_TABLE__,
            count   = __CONSTRUCTOR_COUNT__,
            segment = INIT;
    CONDES: type    = destructor,
            label   = __DESTRUCTOR_TABLE__,
            count   = __DESTRUCTOR_COUNT__,
            segment = RODATA;
    CONDES: type    = interruptor,
            label   = __INTERRUPTOR_TABLE__,
            count   = __INTERRUPTOR_COUNT__,
            segment = RODATA,
            import  = __CALLIRQ__;
}